import { LoadingInterfac } from "./LoadingInterfac";
import { LoadingUniImpl } from './LoadingUniImpl'

export class DefaultFactory{
	
	private static loading:LoadingInterfac
	
	static getInstance():LoadingInterfac{
		if(DefaultFactory.loading){
			return DefaultFactory.loading
		}
		const MODEL_UNI='UNI'
		const models=[MODEL_UNI]
		let model:string = process.env.VUE_APP_TICK_LOADING__MODEL
		model = model || MODEL_UNI
		if(models.indexOf(model) < 0){
			throw "VUE_APP_TICK_LOADING__MODEL 配置错误"
		}
		model = model.toUpperCase()
		
		switch(model){
			case MODEL_UNI:
				DefaultFactory.loading = new LoadingUniImpl();
				break;
				
			default:
		}
		return DefaultFactory.loading
	}
}

export var loading = DefaultFactory.getInstance()